using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace NotAClue.EF.Auditing.Models.Mapping
{
    public class AuditEntryMap : EntityTypeConfiguration<AuditEntry>
    {
        public AuditEntryMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.TableName)
                .IsRequired()
                .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("AuditEntries");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.TableName).HasColumnName("TableName");
            this.Property(t => t.RecordId).HasColumnName("RecordId");
            this.Property(t => t.State).HasColumnName("State");
            this.Property(t => t.CreatedBy).HasColumnName("CreatedBy");
            this.Property(t => t.CreatedOn).HasColumnName("CreatedOn");
        }
    }
}
